package config;

import com.service.UserService;
import com.service.UserServiceImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main {
    public static void main(String[] args) {
        //参数是有@Configuration修饰的配置类
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(HelloConfig.class);

        UserServiceImpl userService = context.getBean("yyy", UserServiceImpl.class);
        System.out.println(userService);

        UserServiceImpl userService2 = context.getBean("yyy", UserServiceImpl.class);
        System.out.println(userService2);

        HelloConfig config = context.getBean(HelloConfig.class);
        System.out.println(config);

        //testInnerConfig();

    }

    static void testInnerConfig() {
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(HelloConfigInnerConfig.class);

        UserService bean = context.getBean(UserService.class);
        System.out.println(bean);

    }
}
